﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RayTracing
{
    class CylinderScene : Scene
    {

        // Camera variables
        Camera camera;
        public float distance;

        public Color backGroundColor;

        // Lights in Scene        
        public AmbientLight ambientLight;
        public DirectionalLight directionalLight;

        //Geometries
        Geometry Cylinder1;
        Geometry Rod1;
        Geometry ball1;

        //Textures
        Texture uv;
        Texture green;
        Texture red;
        Texture blue;

        //Skins
        Skin nonreflective;
        Skin mirror;

        // Scene Objecets
        SceneObject obj1;
        SceneObject obj2;
        SceneObject obj3;


        public override string sceneName()
        {
            return "Adam A's Scene";
        }

        public override void createScene(out List<SceneObject> objects, out List<Light> lights, out Camera camera, float time, float slider1, float slider2, float slider3, float slider4, float slider5)
        {
            // every scene needs these two lines
            objects = new List<SceneObject>();
            lights = new List<Light>();

            // Camera variables
            P3 loc = new P3(0, -5, 0);
            camera = new Camera(loc, new P3(0, 0, 0));

            distance = -5;
            backGroundColor = Color.BLACK;

            // Lights in Scene
            ambientLight = new AmbientLight(new Color(.4f, .4f, .4f));
            directionalLight = new DirectionalLight(new P3(slider1, slider3, slider2), new Color(1.8f, 1.8f, 1.8f));
            //add Lights to the lights list
            lights.Add(ambientLight);
            lights.Add(directionalLight);

            //geometries

            ShiftedObject Cylinder1 = new ShiftedObject(new Cylinder());
            Cylinder1.rotate(new P3(slider5/5, slider4 / 5, time * 30));
            Cylinder1.scale(new P3(2f,2f,2f));
            Cylinder1.translate(new P3(0, 0, 0));
            //Rod1 = new Cylinder(new P3((float)8, (float)20, (float)8), .7f);
            Rod1 = new Sphere(new P3(0, 0, 0), 1);
            ball1 = new Sphere(new P3(0, slider1 * 10, 1), .5f);
            Ray rei = new Ray(new P3(0f, 0f, -.1f), P3.normalize(new P3(0, 1f, 1f)));
            float d1 = Cylinder1.distance(rei);
            //Console.WriteLine("d1 = " + d1);
            Ray rei2 = new Ray(new P3(0f, 0f, 1.1f), P3.normalize(new P3(-1f, 1f, -1f)));
            float d2 = Cylinder1.distance(rei2);
            //Console.WriteLine("d2 = " + d2);
            Ray rei3 = new Ray(new P3(1f, -1f, .5f), P3.normalize(new P3(-1f, -1f, -1f)));
            float d3 = Cylinder1.distance(rei3);
            //Console.WriteLine("d3 = " + d3);
            //textures
            //uv = new ImageTexture(RayTracing.Properties.Resources);
            green = new ImageTexture(RayTracing.Properties.Resources.earthcloudmaptrans);

            //red = new ThreeColorTexture(Color.RED, Color.GRAY, Color.PURPLE);
            red = new ImageTexture(RayTracing.Properties.Resources.neptunemap);
            blue = new ImageTexture(RayTracing.Properties.Resources.earthlights1k);
            //red = new SolidTexture(Color.RED);
            //green = new SolidTexture(Color.GREEN);
            //blue = new SolidTexture(Color.CYAN);
            Texture[] texArr = { red, green, blue };
            Skin[] skinArr = { };
            MultiTexture mTex = new MultiTexture(texArr, skinArr);
            //skins
            nonreflective = new NonReflective();
            mirror = new Mirror();
            // Scene Objects
            obj1 = new SceneObject(Cylinder1, mTex, nonreflective);
            obj2 = new SceneObject(Rod1, uv, nonreflective);
            obj3 = new SceneObject(ball1, green, nonreflective);

            //add objects to theScene
            objects.Add(obj1);
            //objects.Add(obj2);
            //objects.Add(obj3);


        }

        public override String[] SliderLabels()
        {
            String[] sliderLabels = { "Dlight X", "Dlight Z", "Dlight Y", "Not Used", "Not Used" };
            return sliderLabels;
        }
        public override AnimationParamaters getAnimationParamaters()
        {
            return new AnimationParamaters(10, .05f);
        }
    }
}